package com.hs.room.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.hs.room.model.sys.SysDept
import com.hs.room.model.sys.SysRole
import kotlinx.coroutines.flow.Flow

@Dao
interface SysRoleDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertRole(role: SysRole)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertRole(role: List<SysRole>)

    @Query("SELECT * FROM sys_role where :code = code")
    suspend fun selectByCode(code:String) : SysRole

    @Update
    fun update(record: SysRole?): Int

    @Update
    fun update(sysDeptList: List<SysRole?>?): Int


    @Query("SELECT * FROM sys_role")
     fun getAllRoles(): Flow<List<SysRole>>


    @Query("SELECT * FROM sys_role where :sysTemNo = sysTemNo")
    suspend fun selectBySysTemNo(sysTemNo:String) : SysRole

}